package com.mizhiquan.common;

import com.google.common.collect.Sets;

import java.text.SimpleDateFormat;
import java.util.Set;

/**
 * 常量类
 */
public class Const {

    public static final String APP_NAME = "觅知圈"; //请勿随意修改，否则业务将受影响，邮件推送时邮件发件人会显示，短信推送时短信签名会显示...

    //TODO：//切记，上线时务必改成网站的域名，测试时请填写项目的地址，格式为"协议://域名:端口/"
    public static final String APP_URL = "http://localhost:8080/";
    //当前用户
    public static final String CURRENT_USER = "currentUser";

    //邮箱
    public static final String EMAIL = "email";

    //用户名
    public static final String USERNAME = "username";

    //手机号
    public static final String PHONE = "phone";

    //设置短信超时时间为10分钟
    public static final Integer SMSTimeOut = 10;

    //设置邮件超时时间为60分钟
    public static final Integer EMAILTimeOut = 60;

    //阿里云ak&secret
    public static final String accessKeyId = "LTAIBYyYKhd6vECB";
    public static final String accessKeySecret = "KLqOqME3PYmkfwFKLNU4IQFHpUvxvR";

    //oss 区域
    public static final String ENDPOINT = "http://oss-cn-beijing.aliyuncs.com";

    //设置标准时间格式
    public static final SimpleDateFormat SDF_FULL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static final SimpleDateFormat SDF_DAY = new SimpleDateFormat("yyyy-MM-dd");

    //回答列表排序方式枚举
    public interface asklistOrderBy{
//        Set<String> ORDERBY_ASKTIME = Sets.newHashSet("askTime desc","askTime asc");
        Set<String> ORDERBY_ASKTIME = Sets.newHashSet("ask_time%desc","ask_time%asc");
    }


    //用户类型枚举
    public interface Role{
        int ROLE_CUSTOMER = 1; //普通用户
        int ROLE_ADMIN = 2; //管理员
        int ROLE_BANED = 3; //小黑屋
        int ROLE_PRE_REG = 4; //预注册用户
    }

    //用户来源枚举
    public interface From{
        int FromWeb = 1; //网站注册
        int FromQQ = 2; //QQ一键
        int FromWechat = 3; //微信扫码
    }

    //错误枚举
    public interface Error{
        String NO_SUCH_ITEM = "NO_SUCH_ITEM";
    }


    //对象存储枚举
    public enum BucketName {
        PIC(1,"mizhi-img"),
        FILE(2,"mizhi-file")
        ;
        BucketName(int code, String value){
            this.value = value;
            this.code = code;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static BucketName codeOf(int code){
            for (BucketName BucketName:values()){
                if (BucketName.getCode() == code){
                    return BucketName;
                }
            }
            throw new RuntimeException("没有找到对应枚举");
        }

    }

    public enum SMSTemplet {
        REGISTER(1,"SMS_77285007")
        ;
        SMSTemplet(int code, String value){
            this.value = value;
            this.code = code;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static SMSTemplet codeOf(int code){
            for (SMSTemplet SMSTemplet:values()){
                if (SMSTemplet.getCode() == code){
                    return SMSTemplet;
                }
            }
            throw new RuntimeException("没有找到对应枚举");
        }

    }

    //支付宝接口回调
    public interface AlipayCallback{
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILD = "faild";
    }

    //支付状态
    public enum OrderStatusEnum {
        CANCELED(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAID(20,"已付款"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭")
        ;

        OrderStatusEnum(int code,String value) {
            this.value = value;
            this.code = code;
        }

        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static OrderStatusEnum codeOf(int code){
            for (OrderStatusEnum orderStatusEnum:values()){
                if (orderStatusEnum.getCode() == code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应枚举");
        }
    }

    //支付平台
    public enum PayPlatformEnum{
        Alipay(1,"支付宝")
        ;
        private int code;
        private String value;

        PayPlatformEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public int getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }
    }

    //支付方式枚举
    public enum PaymentTypeEnum{
        ONLINE_PAY(1,"在线支付");
        ;

        PaymentTypeEnum(int code,String value) {
            this.value = value;
            this.code = code;
        }

        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static PaymentTypeEnum codeOf(int code){
            for (PaymentTypeEnum paymentTypeEnum:values()){
                if (paymentTypeEnum.getCode() == code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应枚举");
        }
    }
}
